/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef IMAGE_KNIFE_C_KEKE_PROMISE_C_H
#define IMAGE_KNIFE_C_KEKE_PROMISE_C_H

#include <future>
#include "promise.h"

namespace ImageKnifePro {
template<typename T>
class PromiseC : public Promise<T> {
public:
    std::shared_future<T> GetFuture()
    {
        return promise_.get_future().share();
    }
private:
    std::promise<T> promise_;

    void SetValue(T value)
    {
        promise_.set_value(value);
    }
};

template<>
class PromiseC<void> : public Promise<void> {
public:
    std::shared_future<void> GetFuture()
    {
        return promise_.get_future().share();
    }
private:
    std::promise<void> promise_;

    void SetValue() override
    {
        promise_.set_value();
    }
};

}
#endif //IMAGE_KNIFE_C_KEKE_PROMISE_C_H
